import Vue from 'vue'
import VueRouter from 'vue-router'
import Loign from '../views/loign.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',
    name: 'Loign',
    component: Loign
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import( '../views/Home.vue'),
    meta:{
      isLogin:true,
    },
    children:[
      {
        path:'/home/tablea',
        name: 'tablea',
        component: () => import( '../components/TableA.vue'),
        meta:{
          isLogin:true,
          roles:['admin','user']
        }
      },
      {
        path:'/home/tableb',
        name: 'tableb',
        component: () => import('../components/TableB.vue'),
        meta:{
          isLogin:true,
          roles:['admin']
        },
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
